/*
 * @Author: your value
label:'',
 * @Date: 2021-11-19 09:44:41
 * @LastEditTime: 2023-05-18 17:14:13
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \V9_Dev\src\enum\baseModule\apiEnum.js
 */
import { createEnumObject } from '/~/utils/data/createEnumObject';

export enum apiEnum {
  AUDITS = 'audits',
  OPTIONS = 'operations',
  APIS = 'apis',
}
export type apiType = 'audits' | 'operations' | 'apis';
interface IApiMethods {
  [x: number]: {
    value: ApiNames;
    label: string;
    method: 'get' | 'post';
    order?: number;
    type: apiType;
    loading: boolean;
  };
}
export type ApiNames =
  | 'list'
  | 'get'
  | 'delete'
  | 'save'
  | 'submit'
  | 'audit'
  | 'withdraw'
  | 'discard'
  | 'reject';
export const apiMaps: IApiMethods = {
  // 查列表  2^0
  [1 << 0]: {
    value: 'list',
    label: '列表',
    method: 'post',
    type: apiEnum.APIS,
    loading: false,
  },
  // 查详情  2^1
  [1 << 1]: {
    value: 'get',
    label: '详情',
    method: 'get',
    type: apiEnum.APIS,
    loading: true,
  },
  // 删列表 2^2 4
  [1 << 2]: {
    value: 'delete',
    label: '删除',
    method: 'post',
    order: 7,
    type: apiEnum.OPTIONS,
    loading: true,
  },
  // 保存 或者 保存且提交  2^3 8
  [1 << 3]: {
    value: 'save',
    label: '编辑',
    method: 'post',
    type: apiEnum.OPTIONS,
    loading: true,
  },
  // 提交 16
  [1 << 4]: {
    value: 'submit',
    label: '提交',
    method: 'post',
    order: 1,
    type: apiEnum.AUDITS,
    loading: true,
  },
  // 审核  32
  [1 << 5]: {
    value: 'audit',
    label: '审核',
    method: 'post',
    order: 2,
    type: apiEnum.AUDITS,
    loading: true,
  },
  // 撤回 64
  [1 << 6]: {
    value: 'withdraw',
    label: '撤回',
    method: 'post',
    order: 3,
    type: apiEnum.AUDITS,
    loading: true,
  },
  // 作废 128
  [1 << 7]: {
    value: 'discard',
    label: '作废',
    method: 'post',
    order: 4,
    type: apiEnum.AUDITS,
    loading: true,
  },
  // 拒绝 256
  [1 << 8]: {
    value: 'reject',
    label: '拒绝',
    method: 'post',
    order: 5,
    type: apiEnum.AUDITS,
    loading: true,
  },
};

export const auditOperations = createEnumObject(
  Object.values(apiMaps).filter((item) => {
    return ['audit', 'reject'].includes(item.value);
  }),
);
